package br.com.agiledev.webscrum.action;

import java.util.Arrays;

import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;

import br.com.agiledev.webscrum.entity.Product;

@SuppressWarnings("serial")
@Name("productSearchMB")
@Scope(ScopeType.PAGE)
public class ProductSearchAction extends QueryAction<Product> {

    private static final String EJBQL = "select pr from Product pr";
    private static final String[] RESTRICTIONS = {"lower(pr.nome) like lower(concat(#{productSearchMB.product.nome}, '%'))"};
    private static final String ORDER_COLUMN = "pr.nome";
    
    private Product product;
    
    public ProductSearchAction() {
	setEjbql(EJBQL);
	setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
	setOrderColumn(ORDER_COLUMN);
    }
    
    //Get's / Set's
    public Product getProduct() {
	if(product == null) {
	    product = new Product();
	}
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

 
}